﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebeTerm.WebControls;
using WebeTerm.DbBusiness;
using System.Threading;

namespace WebeTerm.Web.Pages.PlugIns.TemplateControls
{
    public partial class MyPlugIns : ListControlBase
    {
        protected override void LoadData()
        {
            WebeTerm.Common.Pages pages = BuildPages();
            var sql = new CompanyPlugInsBLL().All().Join(new PlugInsBLL().All(), l => l.PlugInCode, r => r.PlugInCode, (l, r) => new {
                l.Id,
                l.PlugInCode,
                r.PlugInName,
                l.LastTryDate,
                l.PlugInJSon,
                l.ExpireDate,
                l.Interval,
                r.IsPublic,
                r.IsValid,
                r.PlugInAssembly,
                r.Sequence
            });
            this.rptPlugIns.DataSource = sql.OrderBy(l=>l.Sequence).Take(pages.RecordPaginal).Skip((pages.PageNumber - 1) * pages.RecordPaginal).Distinct().ToList();
            pages.RecordSum = sql.Count();
            PageControler.PagesInfo = pages;
            this.rptPlugIns.DataBind();
        }
    }
}